#include <iostream>
#include <algorithm>
using namespace std;

const int N = 100010;
struct range
{
    int l, r;
    bool operator<(const range &w)
    {
        return r < w.r;
    }
} ranges[N];

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        int l, r;
        cin >> l >> r;
        ranges[i] = {l, r};
    }
    sort(ranges, ranges + n);
    int res = 0, ed = -2e9;
    for (int i = 0; i < n; ++i)
    {
        if (ranges[i].l > ed)
        {
            ed = ranges[i].r;
            ++res;
        }
    }
    cout << res << endl;
    return 0;
}
